package com.ysq.tankgame;

import java.util.Vector;

/*
 * 我的坦克类
 */
public class MyTank extends Tank {
    Shot shot = null;
    Vector<Shot> shots = null;
    boolean isLive = true;

    public boolean isLive() {
        return isLive;
    }

    public void setLive(boolean isLive) {
        this.isLive = isLive;
    }

    public MyTank(int x, int y) {
        super(x, y);
        this.setSpeed(5); // 设置坦克的速度
        shots = new Vector<>();
    }

    /*
     * 发射子弹
     */
    public void shotEnemyTank(int x, int y, int direct) {
        switch (getDirect()) {
            case 0: // 向上
                shot = new Shot(getX() + 15, getY(), getDirect());
                shots.add(shot);
                new Thread(shot).start();
                break;
            case 1: // 向右
                shot = new Shot(getX() + 60, getY() + 15, getDirect());
                shots.add(shot);
                new Thread(shot).start();
                break;
            case 2: // 向下
                shot = new Shot(getX() + 15, getY() + 60, getDirect());
                shots.add(shot);
                new Thread(shot).start();
                break;
            case 3: // 向左
                shot = new Shot(getX(), getY() + 15, getDirect());
                shots.add(shot);
                new Thread(shot).start();
                break;
        }
    }

    public Vector<Shot> getShots() {
        return shots;
    }
    
}
